/**
* @description : 卷烟品牌查询
* @descriptionDetail : 卷烟品牌查询
* @copyright : 浙江烟草
* @author : mc
* @create : 2022-12-05 15:33:20
*/
<template>
  <view>
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
      <view class="nav-right-icon">
        <u-icon name="scan" color="#FFF" @tap="scan"></u-icon>
      </view>
    </theme-navbar>
    <!-- #endif -->
    <!-- #ifdef H5-WECHAT || H5-EMP -->
    <fab-button :content="fContent" @fabtrigger="fabtrigger" />
    <!-- #endif -->
    <view class="content u-page">
      <!-- 内容区 -->
      <view class="nolicence-search-lay" :style="{'top': isHideNav ? 0 : '44px'}">
        <u-search class="nolicence-search" shape="round" :clearabled="true" :showAction="true" actionText="确定" :animation="true"
          placeholder="请输入品牌名称/烟码" v-model="keyword" @custom="searchClick"></u-search>
      </view>
      <view class="main">
        <me-table :i="0" :index="0" :top="80" :initLoad="false" :load-data="loadData" :height="getListViewHeight()"
          ref="mescrollItem0">
          <view slot-scope="d">
            <logo-info :cigar="d.data" class="smoke_info_item"></logo-info>
          </view>
        </me-table>
      </view>
    </view>
  </view>
</template>

<script>
import meTable from '@/components/me-table.vue';
import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
import LogoInfo from "./components/logoInfo";
import zjCommonService from "@/service/common/common.service";
import commonService from "@/service/case/case.service.js";
import fabButton from '@/components/uni-fab.vue';

export default {
  components: {
    meTable,
    LogoInfo,
    fabButton
  },
  mixins: [MescrollMoreMixin,],
  data () {
    return {
      // 搜索框关键字
      keyword: "",
      fContent: [{
        iconPath: require('@/static/scode.png'),
        selectedIconPath: require('@/static/scode.png'),
        text: '扫一扫',
        active: false,
      }],
    };
  },
  mounted () {
    this.setRightBtns();
    this.init();
  },
  methods: {
    /**
     * 初始化
     */
    init () { },
    setRightBtns () {
      // 设置右侧标题
      // #ifdef H5-DINGDING
      console.log("设置标题", this.tabIndex);
      this.$deviceApi.setRight("扫一扫", () => {
        // 添加日计划操作
        this.scan();
        this.setRightBtns();
      }, true, true);
      // #endif
    },
    fabtrigger (btn) {
      if (btn.index == 0) {
        this.scan();
      }
    },
    /**
     * 筛选数据
     */
    searchClick (val) {
      let mescroll = this.getMescroll(this.tabIndex);
      mescroll.triggerDownScroll();
    },
    getListViewHeight () {
      let x = "0px";
      // #ifdef H5-DINGDING
      x = (this.$u.sys().windowHeight - 50 - this.$u.sys().statusBarHeight) + "px";
      // #endif
      // #ifndef H5-DINGDING || H5-WECHAT
      x = (this.$u.sys().windowHeight - 50 - 44 - this.$u.sys().statusBarHeight) + "px";
      // #endif
      return x;
    },
    scan () {
      // #ifdef H5-DINGDING
      this.$deviceApi.scan().then(res => {
        this.keyword = res;
        let mescroll = this.getMescroll(this.tabIndex);
        mescroll.triggerDownScroll();
      });
      // #endif
      // #ifdef H5-WECHAT || H5-EMP
      this.$deviceApi.scan().then(res => {
        console.log('--- H5-EMP', res)
        this.keyword = res;
        let mescroll = this.getMescroll(this.tabIndex);
        mescroll.triggerDownScroll();
      });
      // #endif
      // #ifndef H5-DINGDING

      // this.$modal.toast("使用钉钉打开");

      // #endif
    },
    loadData (page) {
      let self = this;
      return new Promise((resolve, reject) => {
        commonService.getCigaretteList(page.num, page.size, {
          keyword: this.keyword,
        }).then(res => {
          if (res.success) {
            resolve({
              data: res.data,
              count: res.count,
            });
          } else {
            self.$modal.alert(res.msg);
            resolve({
              data: [],
            });
          }
        }).catch(err => {
          self.$modal.alert("请求失败");
          resolve({
            data: [],
          });
        });
      });
    },
    /**
     * 跳转个人的具体任务条目内容页面
     */
    showDetail (data) {
      const params = {
        retailerUuid: data.retailerUuid,
      };
      this.setRouteParam(params);
      this.$u.route(this.detailPath);
    },
  },
};
</script>

<style lang="scss" scoped>
@import '@/style/common/rightMenu.scss';

.nolicence-search-lay {
  background-color: #fff;
  position: fixed;
  // #ifndef H5-DINGDING
  top: 44px;
  // #endif
  // #ifdef H5-DINGDING
  top: 0px;
  // #endif
  z-index: 999;
  width: 100%;
  overflow: hidden;
}

.nolicence-search {
  margin: 10rpx 40rpx !important;
}

.main {
  background-color: $uni-bg-color-grey;
}

.dataTab {
  width: 730rpx;
  margin-left: 10rpx;
}

.name_a {
  color: blue;
}

.smoke_info_item {
  float: left;
  overflow: hidden;
  margin: 15px 10px 0px;
  background-color: #ffffff;
  border-radius: 30rpx;
}

.smoke_info_item:nth-child(2) {
  margin-top: 0;
}

.scoll_content {
  background-color: #eff3f9;
}
</style>
